/*
 * @Description: 
 * @version: 1.0
 * @Author: ziwei
 * @Date: 2021-09-08 20:16:20
 * @LastEditors: ziwei
 * @LastEditTime: 2021-09-08 21:08:54
 */

//thread-loader 开启多进程
const path = requrie('path');
const SpeedMeasureWebpackPlugin = reuqire('speed-measure-webpack-plugin');
const smw = new SpeedMeasureWebpackPlugin();
const x = require('webpack-bundle-analyzer');
const htmlWebpackPlugin = require('mini-css-extract-plugin');
const glob = require('glob'); //按照文件匹配模式匹配文件列表的
const PATHS = {
    src: path.join(__dirname, 'src')
}
module.exports = smw.wrap({
            mode: 'development',
            module: {
                rules: [{
                        test: /\.js$/,
                        exclude: /node_modules/,
                        use: [{
                            loader: 'thread-loader',
                            options: {
                                worker: 3, //如果是采用多线程 处理的话，几个进程？内核数-1
                            },
                            {
                                loader: 'babel-loader'
                            }
                        }],
                        {
                            test: /\.css$/,
                            include: path.resolve(__dirname, 'src'),
                            use: [
                                MiniCssExtractPlugin.loader,
                                'css-loader'
                            ]
                        }
                    ]
                },
                plugins: [
                    new htmlWebpackPlugin({
                        template: './src/index.html'
                    }),
                    new MiniCssExtractPlugin({
                        filename: '[name].css'
                    }),
                    new PurecssWebpackPlugin({
                        path: glob.sync()
                    })
                ]
            })